// My Computer Program for PCMod (SERVER)

PROG.PName = "MyComputer"
PROG.Author = "[GU]|ZLC|thomasfn"

// Here we will load all our programs
if (!ProgramList) then
	ProgramList = {}
	function ProgramList:Register( PName, Program )
		ProgramList[PName] = Program
	end
end

function PROG:Initialize( pl )
	SendClientProgram( pl, "MyComputer" )
	SendClientWindow( pl, "Main" )
end

function PROG:PC_Changed( pl, pc )
	self:CommandRecieved( pl, "update", {} )
end

function PROG:Unload()
	
end

function PROG:Think()

end

function PROG:CommandRecieved( ply, command, args )
	local pc = ply.CurrentPC
	if (!pc) then return end
	if (command == "setdc") then
		local r = args[1]
		local g = args[2]
		local b = args[3]
		PCBeam:SetValue( pc, "OS_DesktopR", r )
		PCBeam:SetValue( pc, "OS_DesktopG", g )
		PCBeam:SetValue( pc, "OS_DesktopB", b )
	end
	if (command == "setpip") then
		pc.Data[ pc:EntIndex() ].P_IP = tonumber(args[1])
	end
	if (command == "update") then
		BeamData_Int( ply, "p_ip", pc.Data[ pc:EntIndex() ].P_IP )
	end
	if (command == "changepass") then
		local old = args[1]
		local new = args[2]
		local actual = pc.Password
		if (old != actual) then
			BeamData_String( ply, "pinfo", "Password incorrect!" )
		else
			pc.Password = new
			BeamData_String( ply, "pinfo", "Password changed!" )
		end
	end
	if (command == "quit") then
		UnloadProgram( ply )
	end
end

function PROG:PacketRecieved( packet, pc )

end
